package io.renren.generate.service;

import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.Query;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.renren.generate.GeneratorDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Auther: tianchao
 * @Date: 2020/11/29 20:00
 * @Description:
 */
@Service
public class SysGeneratorService {

    @Autowired
    private GeneratorDao generatorDao;

    public PageUtils queryList(Map<String,Object> params) {
        IPage<Map<String,String>> page = new Query<Map<String,String>>().getPage(params);
        IPage<Map<String,String>> result =this.generatorDao.queryList(page, params);
        //int total = (int) page.getTotal();
//        if (generatorDao instanceof MongoDBGeneratorDao) {
//            total = MongoDBCollectionFactory.getCollectionTotal(query);
//        }

        return new PageUtils(result);
    }

    /**
     * 查询数据库名字
     * @return
     */
    public List<String> queryDataBaseNamesAll(){
        return generatorDao.queryDataBaseNamesAll();
    }
}
